package com.zerui.manager.web.enums;

import lombok.Getter;

/**
 * @Author wh
 * @create_time 2023-08-25 14:23
 */

@Getter
public enum DeviceOperateEnum {

    OPEN_DOOR("open_door","remoteOpenDoor","开门"),

    NORMALLY_OPEN("normally_open","normalOpen","常开"),

    NORMALLY_OFF("normally_off","normalClose","常闭"),

    NORMALLY_CLOSE("normally_close","remoteCloseDoor","关门"),

    NORMALLY_WORKING("normally_working", "normalWorking", "普通")
    ;

    private final String code;

    private final String action;

    private final String name;

    DeviceOperateEnum(String code, String action,String name) {
        this.code = code;
        this.action = action;
        this.name = name;
    }

    public static String getActionByCode(String code){
        DeviceOperateEnum[] values = DeviceOperateEnum.values();
        for (DeviceOperateEnum deviceOperateEnum:values){
            if(deviceOperateEnum.getCode().equals(code)){
                return deviceOperateEnum.getAction();
            }
        }
        return null;
    }

    public static DeviceOperateEnum getDeviceOperateEnum(String code){
        DeviceOperateEnum[] values = DeviceOperateEnum.values();
        for (DeviceOperateEnum deviceOperateEnum:values){
            if(deviceOperateEnum.getCode().equals(code)){
                return deviceOperateEnum;
            }
        }
        return null;
    }

}
